Make scaling type configurable for MoE training#2642
Merged
danielvegamyhre merged 1 commit intomainfrom Aug 5, 2025
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2642
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
danielvegamyhre
added a commit
that referenced
this pull request
Jul 30, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
507b6cc to
4fbf578
Compare
This was referenced Jul 30, 2025
danielvegamyhre
added a commit
that referenced
this pull request
Jul 31, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
4fbf578 to
1434e9b
Compare
1434e9b to
a5403ac
Compare
danielvegamyhre
added a commit
that referenced
this pull request
Jul 31, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
danielvegamyhre
added a commit
that referenced
this pull request
Jul 31, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
a5403ac to
a828d09
Compare
danielvegamyhre
added a commit
to pytorch/torchtitan
that referenced
this pull request
Aug 1, 2025
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
danielvegamyhre
added a commit
to pytorch/torchtitan
that referenced
this pull request
Aug 1, 2025
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
danielvegamyhre
added a commit
to pytorch/torchtitan
that referenced
this pull request
Aug 1, 2025
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
danielvegamyhre
added a commit
to pytorch/torchtitan
that referenced
this pull request
Aug 1, 2025
- For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
danielvegamyhre
added a commit
to pytorch/torchtitan
that referenced
this pull request
Aug 1, 2025
- For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
vkuzo
approved these changes
Aug 1, 2025
Contributor
vkuzo
left a comment
There was a problem hiding this comment.
lg for prototype, we might need to change this later
danielvegamyhre
added a commit
that referenced
this pull request
Aug 1, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
a828d09 to
82e707e
Compare
e9ba18b to
2aabb15
Compare
danielvegamyhre
added a commit
that referenced
this pull request
Aug 1, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
82e707e to
1b362ee
Compare
danielvegamyhre
added a commit
that referenced
this pull request
Aug 1, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
1b362ee to
bb05933
Compare
danielvegamyhre
added a commit
that referenced
this pull request
Aug 4, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
bb05933 to
df8adf3
Compare
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
df8adf3 to
a221a9e
Compare
bentherien
pushed a commit
to bentherien/torchtitan_
that referenced
this pull request
Aug 5, 2025
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
joellidin
pushed a commit
to one-covenant/torchtitan
that referenced
this pull request
Aug 8, 2025
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
joellidin
pushed a commit
to one-covenant/torchtitan
that referenced
this pull request
Aug 8, 2025
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
liangel-02
pushed a commit
that referenced
this pull request
Aug 25, 2025
stack-info: PR: #2642, branch: danielvegamyhre/stack/26
xrsrke
pushed a commit
to NousResearch/torchtitan
that referenced
this pull request
Feb 13, 2026
## Summary - For mxfp8, token group sizes must be multiples of "block_size" because in the backward pass for `grad_weight = grad_output_t @ input`, the "M" (token) dimension is the contracting dimension, and each token group is a logically distinct subtensor, so we scale them separately. This means token groups contracting dimension must be divisible by the mxfp8 block_size (default 32). Here is a diagram showing the problem: https://www.internalfb.com/excalidraw/EX521879 - To solve this, this PR makes the token group M aligment configurable. ## Test plan - Integration test with torchao passes: pytorch/ao#2642 - Did manual test run with llama4 debug model using bf16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked PRs:
Make scaling type configurable for MoE training
Summary
Test plan